$(function(){
	fillDepartments();
});

function fillDepartments() {
	
	var depts = $("#depts");
	$.getJSON("../../admin/department/department!bytype", {
		"bean.id" : "root",
		"bean.departmentType": "Manufacture"
	}, function(data, textStatus, jqXHR) {

		$.each(data, function(i, item) {
			var li = $("<button did='"+item.id+"' type='button' class='btn btn-info'>"+item.name+"</button>");
            if(fromid==item.id) li.attr("disabled",true);
			li.bind("click",function(){
				$("#todept").val($(this).attr("did"));	
				$("form").get(0).submit();			
			});
			depts.append(li);
			
		});			
		
	});
}